/* 
 * File:   pong.h
 * Author: iezahel
 *
 * Created on December 27, 2008, 5:42 PM
 */

#ifndef _PONG_H
#define	_PONG_H

#include <SDL/SDL.h>
#include <SDL/SDL_net.h>
#include <SDL/SDL_thread.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_ttf.h>

#include <stdlib.h>
#include <stdio.h>

#include <unistd.h>
#include <getopt.h>

#include <sys/socket.h>
#include <arpa/inet.h>

#include <errno.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define SQR(a) ((a) * (a))

#define DEFAULT_PORT_NUMBER 6666

#define DEFAULT_SCREEN_WIDTH 800
#define DEFAULT_SCREEN_HEIGHT 600
#define SCREEN_BPP 32

#define DEFAULT_PLAYER_SIZE 200  /* The size of the player (in pixels) */

#define DEFAULT_PLAYER_SPEED 150 /* pixels per second */
#define DEFAULT_BALL_SPEED 200 /* pixels per second */

#define DEFAULT_SERVER_POSITION 1

#define DEFAULT_FONT_SIZE 28

#define BALL_FILE_NAME "ball.bmp"
#define PLAYER_FILE_NAME "player.bmp"
#define FONT_FILE_NAME "game_font.ttf"

typedef enum GAME_ERROR_CODES {
    GAME_ERROR_NONE = 0,

    GAME_ERROR_SDL,
    GAME_ERROR_SDL_NET,
    GAME_ERROR_SDL_TTF,

    GAME_ERROR_BAD_OPPONENT,
    GAME_ERROR_NETWORK_SOCKET,
    GAME_ERROR_NETWORK_SEND,
    GAME_ERROR_NETWORK_RECV,
    
    GAME_ERROR_NO_DATA,
    GAME_ERROR_NO_CONNECTION,

    GAME_ERROR_LOAD_IMAGE,
    GAME_ERROR_NO_FONT,
    
    GAME_ERROR_UNDEFINED,
} GAME_ERROR_CODES;


#define GAME_PLAYER_POS_LEFT 0
#define GAME_PLAYER_POS_RIGHT 1

SDL_Surface* LoadImage(const char* filename);
TCPsocket InitServerConnection(short host_port);
TCPsocket InitClientConnection(const char* hostname, short host_port);
#endif	/* _PONG_H */

